const fetchBannerList = () => {
  let list = [];
  for (let index = 0; index < 3; index++) {
    list = list.concat({
      "id|+1": index + 1,
      title: "@cname",
      url: "@image('960x480')",
    });
  }
  return list;
};

const fetchPagingList = (size) => {
  let list = [];
  for (let index = 0; index < size; index++) {
    list = list.concat({
      "id|+1": index + 1,
      title: "@cname",
      url: "@image('150x100')",
      discription: "@sentence",
      createTime: "@datetime",
    });
  }
  return list;
};

const fetchUserList = (size) => {
  let list = [];
  for (let index = 0; index < size; index++) {
    list = list.concat({
      "id|+1": 1, // 用户ID，初始值为1，每次自增1
      name: "@cname", // 中文名字
      username: "@name", // 中文名字
      email: "@email", // 随机邮箱
      phone: /^1[34578]\d{9}$/, // 随机手机号码
    });
  }
  return list;
};

export default [
  {
    url: "/api/banner/list",
    method: "get",
    response: () => {
      const list = fetchBannerList();
      return {
        code: 200,
        data: list,
      };
    },
  },
  {
    url: "/api/swiper/list",
    method: "get",
    response: () => {
      const list = fetchBannerList();
      return {
        code: 200,
        data: list,
      };
    },
  },
  {
    url: "/api/paging/list",
    method: "get",
    response: (options) => {
      const urlParams = new URLSearchParams(options.url.split("?")[1] || "");
      const list = fetchPagingList(urlParams.get("limit"));
      console.log(list, urlParams, "urlParams");
      return {
        code: 200,
        total: 12,
        data: list,
      };
    },
  },
  {
    url: "/api/user/list",
    method: "get",
    response: (options) => {
      const urlParams = new URLSearchParams(options.url.split("?")[1] || "");
      const list = fetchUserList(urlParams.get("limit"));
      return {
        code: 200,
        total: 12,
        data: list,
      };
    },
  },
];
